﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HelloWPF.Study.DataBinding
{
    /// <summary>
    /// DPValueValidation2.xaml 的交互逻辑
    /// </summary>
    public partial class DPValueValidation : Window
    {
        public DPValueValidation()
        {
            InitializeComponent();
        }

        public int DPValue
        {
            get { return (int)GetValue(DPValueProperty); }
            set { SetValue(DPValueProperty, value); }
        }
        public static readonly DependencyProperty DPValueProperty =
            DependencyProperty.Register("DPValue", typeof(int), typeof(DPValueValidation), new PropertyMetadata(0), new ValidateValueCallback(OnDPValueValidate));

        private static bool OnDPValueValidate(object value)
        {
            if (value == null || int.Parse(value.ToString()) > 200)
            {
                return false;
            }
            return true;
        }
    }
}
